package com.itany.controller;

import com.itany.entity.User;
import com.itany.service.UserService;
import com.itany.vo.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Author：汤小洋
 * Date：2019-12-17 10:25
 * Description：<描述>
 */
@RestController
@RequestMapping("/users")
public class UserControllerFeign {

    @Autowired
    private UserService userService;

    @GetMapping
    public ResponseResult getUserList(){
       return userService.getUserList();
    }

    @GetMapping("/{id}")
    public ResponseResult getUser(@PathVariable Integer id){
        return userService.getUser(id);
    }

    @PostMapping
    public ResponseResult postUser(User user){
        return userService.postUser(user.getUsername(),user.getPassword());
    }

    @DeleteMapping("/{id}")
    public ResponseResult deleteUser(@PathVariable Integer id){
        return userService.deleteUser(id);
    }

    @PutMapping
    public ResponseResult putUser(@RequestParam Map map){ // 此处可以直接使用Map来接收参数
        return userService.putUser(map);
    }

}
